//创建 reducer 这个处理函数
const reducer =(state,action)=>{
    switch (action.type) {
        case 'todosAdd':
            const id = state.length === 0 ? 1 : state[state.length - 1].id + 1;
            return [
                ...state,
                {
                  id,
                  text:action.payload,
                  done: false,
                },
              ]
        case 'todoIsShow':
            return state.map((item) => {
                  if (item.id === action.payload) {
                  return {
                      ...item,
                      done : !item.done
                  }
                   console.log(action.payload,item);
                  }
                  return item;
                });
         case 'todoRemove' :
            return state.filter((item) => item.id !== action.payload);
        case 'geTlocalStorage' :
            return action.payload
        default:
            return state
    }
}
export default reducer